package com.lenovo.leos.letools;

import java.util.List;

import android.test.AndroidTestCase;
import android.util.Log;
import com.lenovo.leos.letools.domain.Folder;
import com.lenovo.leos.letools.domain.LoadFile;
import com.lenovo.leos.letools.lenovodata.BaseNetClientServer;
import com.lenovo.leos.letools.utils.JSONParser;
import com.lenovo.leos.letools.utils.ListFileUseParams;

/**
 * junit test
 * 
 * @author cys
 */
public class TestloadParserJSON extends AndroidTestCase {

	private BaseNetClientServer baseClient;
	
	public TestloadParserJSON(){
		baseClient = new BaseNetClientServer();
	}
	
	public void testparseListDirs() throws Exception{
		//得到根文件夹下 返回的子文件夹信息
		String str = baseClient.listDir(this.getContext(), "1301279145610203981");
		List<Folder> folders = JSONParser.parseListdirs(str);
		if(folders==null){
			Log.i("dirid","===========this dir has no son dir==========");
			return;
		}
		for(Folder folder:folders){
			Log.i("dirid","======="+folder.getId()+":"+folder.getName());
		}
	}
	
	public void testparseListFiles() throws Exception{
		ListFileUseParams lfp = new ListFileUseParams();
		lfp.dirid = "1301279145610203981";
		//得到根文件夹下 返回的子文件夹信息
		String str = baseClient.listFile(this.getContext(),lfp);
		List<LoadFile> loadFiles = JSONParser.parseListFile(str);
		if(loadFiles==null){
			Log.i("file","===========this dir has no son dir==========");
			return;
		}
		for(LoadFile loadFile:loadFiles){
			Log.i("file","======="+loadFile.getId()+":"+loadFile.getFilename());
		}
	}
}
